package com.navinfo.platform.score;

import com.alibaba.fastjson.JSONArray;
import com.navinfo.platform.score.pojo.ScoreEntry;
import com.navinfo.platform.score.utils.FileReader;
import com.navinfo.tripanalysis.common.arithmetic.common.ExtraStatisticData;
import com.navinfo.tripanalysis.common.arithmetic.common.OuterStatisticData;

import java.util.List;

public class test {

    public static void main(String[] args){
        // step1:初期化
        TripScoreService.init();

        String JsonContext = FileReader.ReadFile("C:\\Users\\zhongh\\Desktop\\调试\\trip_statistics_20181126.json");
        JSONArray jsonArray = JSONArray.parseArray(JsonContext);
        List<OuterStatisticData> listObject = jsonArray.toJavaList(OuterStatisticData.class);
        int size = jsonArray.size();
        System.out.println("Size:   " + size);

        /* 空载 0 */
        /* 半载 1 */
        /* 满载 2 */
        // 载重状态
        String loadStatus = "2";
        // 情景附加信息 若不使用设置成null
        ExtraStatisticData extraData = null;

        for (int i = 0; i < size; i++){
            OuterStatisticData tripData = listObject.get(i);
            // 行程总里程
            tripData.setTripMileage(10);
            // 行程总时长
            tripData.setTripDuration(600000);
            // 疲劳驾驶次数
            tripData.setFatigueDrivingNumber(1);
            // 急加速
            tripData.setSharpUpSpeedNumber(20);
            // 急减速
            tripData.setSharpDownSpeedNumber(30);
            // 急踩油门
            tripData.setSharpStepOnGasNumber(50);
            // 超速
            tripData.setSo90Number(2);
            tripData.setSo120Number(1);
            // 怠速
            tripData.setIdleDuration(120000);
            // 空挡滑行
            tripData.setNeutralGearCoastNumber(2);

            // 经济驾驶 时长
            tripData.setEcoDrivingDuration(300000);
            // 行驶过程中手刹使用
            tripData.setDrivingHandbrakeNumber(0);

            // 超转速
            tripData.setSrDuration(60000);
            // 冷引擎启动
            tripData.setVehicleColdStartNumber(1);

            test.cal(tripData, loadStatus, extraData);
        }
    }
    static void cal(OuterStatisticData tripData, String loadStatus, ExtraStatisticData extraData){
        // step2:打分
        List<ScoreEntry> score = TripScoreService.calTripScore(tripData, loadStatus, extraData);
        System.out.println("=====================" + tripData.getTid() + "=====================");
        if(score == null) {
            System.out.println("=====  打分 出错 =====");
        }
        for(ScoreEntry entry:score){
            System.out.println("=====  type = "+ entry.getType() + " model = " +entry.getModel()+ " score = " + entry.getScore() + "============");
        }
//        System.out.println("=====  totleScore = "+ score.get("totleScore") + " safeScore = " + score.get("safeScore") + " ecoScore = " + score.get("ecoScore") + "============");
    }
}
